package com.infocollect.project.api.ui;

import com.infocollect.project.api.entity.TappMenuActionEntity;
import com.infocollect.project.api.req.TappMenuActionReq;
import com.infocollect.project.api.service.ITappMenuActionService;
import com.infocollect.project.form.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 菜单按钮权限
 *
 * @author 刘亚平
 * @since 2019-12-25 10:32:29queryCurrentMenu
 */
@Api(value = "menuAction", tags = "菜单按钮权限")
@RestController
@RequestMapping("menuAction")
public class TappMenuActionController {
    @Autowired
    private ITappMenuActionService menuActionService;

    /**
     * 保存菜单动作
     */
    @ApiOperation("添加菜单动作")
    @PostMapping("addAction")
    public R<String> addAction(@RequestBody TappMenuActionReq req) {
        return menuActionService.addAction(req);
    }

    /**
     * 编辑菜单动作
     */
    @ApiOperation("编辑菜单动作")
    @PostMapping("eidtAction")
    public R<String> eidtAction(@RequestBody TappMenuActionReq req) {
        return menuActionService.eidtAction(req);
    }

    /**
     * 根据ID 获取按钮信息
     */
    @ApiOperation("编辑菜单动作")
    @PostMapping("getActionInfo")
    public TappMenuActionEntity getActionInfo(@RequestParam("id") Long id) {
        return menuActionService.getActionInfo(id);
    }

    /**
     * 根据菜单ID 获取对应按钮权限
     */
    @ApiOperation("编辑菜单动作")
    @PostMapping("getActionByMenuId")
    public R<List<TappMenuActionEntity>> getActionByMenuId(@RequestParam("menuId") Long menuId) {
        return R.newOk(menuActionService.getActionByMenuId(menuId));
    }

    @ApiOperation("删除动作信息")
    @PostMapping("delAction")
    public R<String> delAction(@RequestParam("id") Long id) {
        return menuActionService.delAction(id);
    }
}
